import { HiddenCall } from '../../request/api.js'
const request = new HiddenCall
Page({
  /**
   * 生命周期函数--监听页面加载
   * author 赵美阳
   * date 2019-04-09
   */
  onLoad: function (options) {
    //设置房源编号
    this.setData({
      houseCode: options.houseCode
    })
    //向后台发起获取房源信息的请求
    request.lookHouseNumber(options.houseCode).then((res) => {
      //设置房源信息
      this.setData({ initHouseData: res.result })
      //向后台发起房源信息是否能对用户可见的请求
      request.lookHouseBoolean(options.houseCode).then((res) => {
        //设置房源信息是否可见
        this.setData({
          houseNumberLook: res.result.houseNumberLook,
        })
      })
    })
  },
  /**
   * 点击修改按钮，跳转到修改房源信息页面
   * author 赵美阳
   * date 2019-04-09
   */
  editHouseInfo: function(){
    //将房源信息，是否可见参数带到修改页面
    var obj = {
      houseNumberLook: this.data.houseNumberLook,
      initHouseData: this.data.initHouseData,
      houseCode: this.data.houseCode
    }
    wx.navigateTo({
      url: `/pages/housenum_edit/index?data=${JSON.stringify(obj)}`
    })
  }
})